import request from "@/utils/request.js"

const name="retail"

export default {
  getList() {
    return request({
      url: '/retail',
      method: 'get'
    });
  },
  findAll(type,page, size) {
    return request({
      url: `/${name}/${type}/${page}/${size}`,
      method: 'get'
    });
  },
  search(searchMap, page, size) {
    return request({
      url: `/${name}/search/${page}/${size}`,
      method: 'post',
      data: searchMap
    });
  },
  save(pojo) {
    return request({
      url: `/${name}`,
      method: 'post',
      data: pojo
    });
  },
  findById(id) {
    return request({
      url: `/${name}/${id}`,
      method: 'get',
    });
  },
  update(id, pojo) {
    if (id == null || id == '') {
      return this.save(pojo)
    }
    return request({
      url: `/${name}/${id}`,
      method: 'put',
      data:pojo
    });
  },
  deleteById(id) {
    return request({
      url: `/${name}/${id}`,
      method: 'delete',
    });

  },
  updateStatus(id)
  {
    return request({
      url: `/retail/status/${id}`,
      method: 'put'
    });
  }
}
